package com.readbook.service;

import com.readbook.dao.WbookdetailDao;
import com.readbook.dao.WdsjDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class WdsjService {
    @Autowired
    private WdsjDao wdsjDao;
    @Autowired
    private WbookdetailDao wbookdetailDao;

    public List<Map<String, Object>> findBookPlanPage(Map<String, Object> gmap) {
        List<Map<String, Object>> list1 = wdsjDao.findBookPlanPage(gmap);
        return list1;
    }


    public int countBookPlanPage(Map<String, Object> gmap) {
        return wdsjDao.countBookPlanPage(gmap);
    }


    public List<Map<String, Object>> findCollectionPage(Map<String, Object> gmap) {
        List<Map<String, Object>> list1 = wdsjDao.findCollectionPage(gmap);
        return list1;
    }


    public int countCollectionPage(Map<String, Object> gmap) {
        return wdsjDao.countCollectionPage(gmap);
    }


    public int sendDiscuss(Map<String, Object> gmap) {
        return wdsjDao.sendDiscuss(gmap);
    }


    public int discussthumbsupAdd(Map<String, Object> gmap) {
        return wdsjDao.discussthumbsupAdd(gmap);
    }


    public int discussthumbsupSub(Map<String, Object> gmap) {
        return wdsjDao.discussthumbsupSub(gmap);
    }


    /**
     * @author 牟明艳
     * @comments 更多的内部评论
     * @time 2019-8-31 14:42:08
     */
    public List<Map<String, Object>> moreDicussPlByDisid(Map<String, Object> gmap) {
        List<Map<String, Object>> listmap = wbookdetailDao.getDiscussByDisid(gmap);
        return listmap;
    }


    /**
     * @author 牟明艳
     * @comments 提交心得体会
     * @time 2019年8月31日22:24:42
     */
    public int saveReadlearn(Map<String, Object> gmap) {
        return wdsjDao.saveReadlearn(gmap);
    }


    /**
     * @author 牟明艳
     * @comments 提交心得体会图片
     * @time 2019年8月31日22:24:42
     */
    public int savePicture(Map<String, Object> gmap) {
        return wdsjDao.savePicture(gmap);
    }


    /**
     * @author 牟明艳
     * @comments 根据心得体会ID查询更多的评论
     * @time 2019年9月1日12:26:37
     */
    public List<Map<String, Object>> moreReadlearnPlByid(Map<String, Object> gmap) {
        List<Map<String, Object>> listmap = wbookdetailDao.getReadlearnPlByLearnid(gmap);
        return listmap;
    }


    /**
     * @author 牟明艳
     * @comments 提交心得体会评论
     * @time 2019年9月4日19:04:00
     */
    public List<Map<String, Object>> checkReacLearnpl(Map<String, Object> gmap) {
        List<Map<String, Object>> listmap = wdsjDao.checkReacLearnpl(gmap);
        return listmap;
    }


    /**
     * @author 牟明艳
     * @comments 提交心得体会评论
     * @time 2019年9月1日15:25:36
     */
    public int saveReadlearnpl(Map<String, Object> gmap) {
        return wdsjDao.saveReadlearnpl(gmap);
    }

    /**
     * @author 牟明艳
     * @comments 根据心得体会ID查询心得体会内容
     * @time 2019年9月4日19:04:00
     */
    public List<Map<String, Object>> listReadLearnBylearnid(Map<String, Object> gmap) {
        List<Map<String, Object>> listmap = wdsjDao.listReadLearnBylearnid(gmap);
        return listmap;
    }


    /**
     * @author 牟明艳
     * @comments 查询读书打卡记录
     * @time 2019年9月3日21:00:14
     */
    public Map<String, Object> getBookreadLog(Map<String, Object> gmap) {
        Map<String, Object> getmap = wdsjDao.getbookplanBybid(gmap);
        if (getmap.get("PLANID") != null) {
            gmap.put("planid", getmap.get("PLANID").toString());
            //查询读书记录
            List<Map<String, Object>> listmap = wdsjDao.getBookreadLogBybid(gmap);
            if (listmap.size() > 0) {
                getmap.put("logs", listmap);
                //查询读书记录日志图片
                for (int i = 0; i < listmap.size(); i++) {
                    Map<String, Object> logmap = listmap.get(i);
                    if (logmap.get("LOGID") != null) {
                        String logid = logmap.get("LOGID").toString();
                        String code = "readlog";
                        //查询阅读剪影
                        Map<String, Object> ydjy = new HashMap<>();
                        ydjy.put("pid", logid);
                        ydjy.put("code", code);
                        ydjy.put("codename", "ydjy");
                        List<Map<String, Object>> pics = wdsjDao.getPictureByCode(ydjy);
                        logmap.put("pics", pics);

                        //查询好词好句好段
                        Map<String, Object> hchjhd = new HashMap<>();
                        hchjhd.put("pid", logid);
                        hchjhd.put("code", code);
                        hchjhd.put("codename", "hchjhd");
                        List<Map<String, Object>> lishchjhd = wdsjDao.getPictureByCode(hchjhd);
                        logmap.put("lishchjhd", lishchjhd);

                        //查询章节读后感
                        Map<String, Object> zjdhg = new HashMap<>();
                        zjdhg.put("pid", logid);
                        zjdhg.put("code", code);
                        zjdhg.put("codename", "zjdhg");
                        List<Map<String, Object>> liszjdhg = wdsjDao.getPictureByCode(zjdhg);
                        logmap.put("liszjdhg", liszjdhg);
                    }
                }
            }
        }

        return getmap;
    }

    /**
     * @author 牟明艳
     * @comments 积分记录
     * @time 2019年9月4日12:44:31
     */
    public int savejfjl(Map<String, Object> gmap) {
        return wdsjDao.savejfjl(gmap);
    }

    /**
     * @author 牟明艳
     * @comments 读书日志记录
     * @time 2019年9月4日12:44:31
     */
    public int savereadlog(Map<String, Object> gmap) {
        return wdsjDao.savereadlog(gmap);
    }


    /**
     * @author 牟明艳
     * @comments 读书日志记录
     * @time 2019年9月4日12:44:31
     */
    public int updatebookplanJd(Map<String, Object> gmap) {
        return wdsjDao.updatebookplanJd(gmap);
    }


    /**
     * @author 牟明艳
     * @comments 查询当天的读书打卡记录
     * @time 2019年9月4日18:21:27
     */
    public List<Map<String, Object>> getBookreadLogToday(Map<String, Object> gmap) {
        return wdsjDao.getBookreadLogToday(gmap);
    }

    /**
     * @author 牟明艳
     * @comments 检查用户是否已经填写心得体会
     * @time 2019年9月4日19:30:56
     */
    public List<Map<String, Object>> checkReadlearn(Map<String, Object> gmap) {
        return wdsjDao.checkReadlearn(gmap);
    }


    /**
     * @author 牟明艳
     * @comments 查询书籍打卡读书是否超过预期
     * @time 2019年9月22日14:56:10
     */
    public String listTimeCq(Map<String, Object> gmap) {
        return wdsjDao.listTimeCq(gmap);
    }

    /**
     * @author 牟明艳
     * @comments 完成了全部获取剩余全部积分
     * @time 2019年9月22日14:56:10
     */
    public int getSyjfByLogid(Map<String, Object> gmap) {
        return wdsjDao.getSyjfByLogid(gmap);
    }
}


